$(document).ready(function () {
    currentDate();
    langToggle();
});

// 当前日期
function currentDate() {
    document.querySelector('.datebar').innerHTML = '今天是：' + new Date().getFullYear() + '年' + (
        new Date()
        .getMonth() + 1) + '月' + new Date().getDate() + '日 星期' + '日一二三四五六'.charAt(new Date().getDay());
}

// 语言切换
function langToggle() {
    $(function () {
        if (zh_choose === 't') {
            $('#js-langBtn').text('简体中文');
        }
    });
    $(document).on('click', '#js-langBtn', function () {
        if (zh_choose === 't') {
            zh_tran('s');
            $('#js-langBtn').text('繁体中文');
        } else {
            zh_tran('t');
            $('#js-langBtn').text('简体中文');
        }
    });
}

// 轮播图
function banner() {
    var mySwiper = new Swiper('.swiper-container', {
        direction: 'horizontal',
        loop: true,
        autoplay: true,
        autoplay: {
            delay: 5000,
            disableOnInteraction: false
        },
        pagination: {
            el: '.swiper-pagination',
            type: 'bullets',
            clickable: true,
        },
        navigation: {
            nextEl: '.swiper-button-next',
            prevEl: '.swiper-button-prev',
        }
    })
}

// 选项卡
function tabs() {
    var tabMenuItem = $('.section--hot .tabs .tabs__menu-item');
    var tabContentItem = $('.section--hot .tabs .tabs__content-item');
    tabMenuItem.mouseover(function () { 
        var index = $(this).index();
        tabMenuItem.removeClass('tabs__active');
        $(this).addClass('tabs__active');
        tabContentItem.hide();
        tabContentItem.eq(index).show();
    });
}

// 房屋选项卡
function tabsHouse() {
    var tabMenuItem = $('.tabs-house .tabs-house__menu-item');
    var tabContentItem = $('.tabs-house .tabs-house__content > ul');
    tabMenuItem.mouseover(function () { 
        var index = $(this).index();
        tabMenuItem.removeClass('tabs-house__active');
        $(this).addClass('tabs-house__active');
        tabContentItem.hide();
        tabContentItem.eq(index).show();
    });
}

// 跑马灯
function marquee(){
    $(".section--guide .section--guide__right > ul").marquee({
        direction: 'left',    
        duration: 30000,         
        gap: 20,                
        delayBeforeStart: 1000, 
        duplicated: true,      
        startVisible: true,
        pauseOnHover: true  
    });
}